package com.groupbuying.provider.service.impl;

import com.groupbuying.provider.constants.CommonConstants;
import com.groupbuying.provider.dao.StoreCapitalVirtualAccountDao;
import com.groupbuying.provider.domain.StoreCapitalVirtualAccountDO;
import com.groupbuying.provider.service.StoreCapitalVirtualAccountService;
import com.groupbuying.provider.utils.JSONUtils;
import com.groupbuying.provider.utils.R;
import com.groupbuying.provider.utils.ReturnUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;


@Service
public class StoreCapitalVirtualAccountServiceImpl implements StoreCapitalVirtualAccountService {

    private static Logger log = LoggerFactory.getLogger(StoreCapitalVirtualAccountServiceImpl.class);


    @Autowired
    private StoreCapitalVirtualAccountDao storeCapitalVirtualAccountDao;




    @Override
    public List<StoreCapitalVirtualAccountDO> list(Map<String, Object> map) {
        return storeCapitalVirtualAccountDao.list(map);
    }


    @Override
    public StoreCapitalVirtualAccountDO getStoreCapitalVirtualAccountByStoreUuid(String storeUuid) {
        Map<String, Object> params = new HashMap<>();
        params.put("storeuuid", storeUuid);
        params.put("delflag", CommonConstants.COMMON_FLAG_UNDEL);
        List<StoreCapitalVirtualAccountDO> list = storeCapitalVirtualAccountDao.list(params);
        return list != null && list.size() > 0 ? list.get(0) : null;
    }
    @Override
    public R getStoreBankInfo(Map<String, Object> params) {

        Object temp = params.get("storeUuid");
        String storeUuid = temp != null ? temp.toString() : null;

        if (StringUtils.isBlank(storeUuid)) {
            return R.error(JSONUtils.beanToJson(ReturnUtils.paramIsNull()));
        }
        StoreCapitalVirtualAccountDO virtualModel = getStoreCapitalVirtualAccountByStoreUuid(storeUuid);

        return R.ok(JSONUtils.beanToJson(virtualModel));
    }

}
